<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>55社区</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="/theme/default/images/favicon.png">
    <link href="${ctx}/static/phone/css/amazeui.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/phone/css/style.css" rel="stylesheet" type="text/css" />
    <script src="${ctx}/static/phone/js/jquery-1.10.2.min.js"></script>
    <script src="${ctx}/static/phone/js/time.js"></script>
</head>
<body>
<header data-am-widget="header" class="am-header am-header-default sq-head ">
    <div class="am-header-left am-header-nav">
        <a href="javascript:history.back()" class="">
            <i class="am-icon-chevron-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="" class="">注册</a>
    </h1>
</header>
<div style="height: 49px;"></div>
<div class="login-logo">
    <img src="${ctx}/static/phone/images/logo.png" />
</div>
<form id="registerForm" action="#" method="post" onsubmit="return false;">
    <input type="text" name="username"  placeholder="请输入用户名" class="login-name">
    <input type="text" name="phone"  placeholder="请输入手机号" class="login-password">
    <input type="password" name="password"  placeholder="请输入密码" class="login-name">
    <input type="password" name="affirm_password"  placeholder="确认密码" class="login-password">
    <div class="yzm">
        <input type="text" name="code" class="reg-yzm" placeholder="输入验证码" />
        <img src="${ctx}/code.do" alt="" width="100" height="32" class="passcode" style="height:43px;cursor:pointer; margin-left: 50px" onclick="this.src=this.src+'?'">
        <%--<p style="display: none" onclick="refreshCode()">看不清，点击刷新</p>--%>
        <%--<input type="button" class="yzm-hq" value="获取验证码" />--%>
    </div>
    <div class="agree">
        <input type="checkbox" name="checkbox" value="同意" checked="">&nbsp;同意
        <a href="" class="xy">《我的55用户协议》</a>
        <div class="r-login">已有账号，请<a href="login.html" class="l-login">登录</a></div>
    </div>
    <input type="button" id="registerBtn" class="login-btn" value="立即注册">
</form>

<script>

    //刷新验证码
    function refreshCode() {
        var t = new Date();
        $('.passcode').attr("src","${ctx}/code.do?t="+t)
    }
    $('#registerBtn').click(function () {
        var myData = $('#registerForm').serialize();
        console.info(myData)
        $.post( "${ctx}/user/user_register.do",myData,function (data) {
            //登陆成功进入后台 不成功提示重新登陆 并刷新页面
            if (data.state==0){
                window.location.href="${ctx}/phone/login.jsp";
            }else{
                refreshCode();//刷新验证码
                alert(data.msg);//提示错误信息
            }

        },'json');
    })
</script>

</body>
</html>
